package UCM;

import Source.DeleteAirport;
import Views.ViewDeleteAirport;

/**
 *
 * @author Joshua King
 */
public class UCDeleteAirport implements UCController {

    private ViewDeleteAirport view;
    private DeleteAirport model = new DeleteAirport();
    
    public UCDeleteAirport(ViewDeleteAirport view) {
        this.view = view;
        view.loadTo(model);
    }
    /**
Precondition: The manager is logged in, on the view flight UI and has clicked delete flight.

   1. Manager selects airport and clicks delete.
   2. System deletes airport data.
   3. System updates the view airport UI indicating success. 

Postcondition: The manager is on the view airport UI and the airport is deleted.

Unsuccessful Outcomes:

    * 2a) System can't delete data.
         1. System updates the UI informing the manager that the service is currently unavailable. 
    * 2b) System receives notice that an error has occurred.
         1. System updates the UI informing the manager that there was an internal error. 
     */
    public void run() {
        //2. System deletes airport data.
        if (model.deleteAirport()) {
            //3. System updates the view airport UI indicating success.
        } else {
//    * 2a) System can't delete data.
//         1. System updates the UI informing the manager that the service is currently unavailable. 
//    * 2b) System receives notice that an error has occurred.
//         1. System updates the UI informing the manager that there was an internal error.
            view.updateFailure();
        }
        view.updateSuccess();
        
    }

}
